<%@page import="org.apache.jasper.tagplugins.jstl.core.ForEach"%>
<%@page import="kickboxing.model.Newsy"%>
<%@page import="java.util.List"%>
<%@page import="java.util.Iterator"%>
<%@page import="kickboxing.controller.NewsyManager"%>
<%@page import="kickboxing.model.Uzytkownik"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>

<p style=margin-top:-10px;></p>
<style type="text/css">
#tytul{
 text-align: justify;
 font-family:Verdana;
 font-size:22px;
 color: white;
 margin-left: 10px;
 margin-right: 50px;
 text-align: left;
}

</style>
<p id=tytul>Aktualności</p>
		<% 
			NewsyManager man = new NewsyManager();
			List <Newsy> listaPRO =  man.wysietlWszystkieNewsy();
			
			int perPage = 8;
			int size = listaPRO.size()-1;
			int pages;
			int start=0;
			
		    if( request.getParameter("pages") != null && request.getParameter("pages") != "")
		    {
		    	pages = (Integer.parseInt(request.getParameter("pages")));
		    	start = (pages - 1) * perPage;
		    	
		    	if(pages < 1)  pages = 1; 
		    	
		    }
		    else
		    {
		    	pages=1;
		    }
		    
		    int prev = pages - 1;
			int next = pages + 1;
		    
		    //out.println("pages: "+pages+"<br>start: "+start+"<br>size: "+size);
		    
		    for(int i = start; i<start+perPage; i++){
		    	
		    	
		    	if(i>size) break;
		    	
		    	
		    	else{ 
		    		%><div id=aktualnosci>
		    		<div id="akt_tytul">
		    			<%= listaPRO.get(i).getTemat() %>
		    			
		    			
		    		</div>
		    		<br>
		    		<div id="akt_data">
		    			<%= listaPRO.get(i).getData() %>	
		    		</div>
		    		<div id="akt_tresc">
			    		<%
			    			int end = 500;
			    			if( listaPRO.get(i).getTresc().length() < end )
			    			{
			    		%>
			    		<%= listaPRO.get(i).getTresc().trim() %>
			    		<%	
			    			}else
			    			{
			    		%>
			    		<%= listaPRO.get(i).getTresc().trim().substring(0, end) %>
			    		<%	
			    			}
			    			
			    		%>... <a href="index.jsp?id=<%= listaPRO.get(i).getId_newsu() %>&kwiateknapisal=<%= listaPRO.get(i).getTemat() %>">
					<img src=img/mini/wiecej_png.png alt="wiecej">
					</a>	
		    		</font>
		    		
		    		</div><hr>
		    		</div>
		    		<%
		    		
		    }}
		    %>
		    <br><table width=100% border=0 height=1><tr><font color=white>
		    <%
		    if(pages > 1){
		    	out.println("<td align=right width=\"45%\"><a class=next_page href=index.jsp?web=aktualnosci&pages="+prev+">poprzednia strona</a>");
		    }	else {out.println("<td>");}
		    
		    out.println("<td width=\"10%\">");
		    
		    if(pages <= (size/perPage)){
		    	out.println("<td align=left width=\"45%\"><a class=next_page href=index.jsp?web=aktualnosci&pages="+next+">nastepna strona</a>");
		    }	else {out.println("<td>");}
		   
		 	%></table><br>  

			

